import config from '@/config/index.ts';
import { openClient, openFeedBack } from '_t';

const {
  urls: { video, feedback },
  feedbackId,
  storageKey: { firstEntry }
} = config;

export default (localforageIns: any) => {
  // 弹窗地址
  const popupUrl = ref('');
  const getPopupUrl = () => {
    let url = location.href;
    const prefix = url.includes('?') ? '&' : '?';
    url += `${prefix}win=1`;
    return url;
  };
  // 跳转介绍视频
  const jumpVideo = () => {
    openClient({ link: video, mode: 5 });
  };
  // 跳转反馈
  const jumpFeedBack = () => {
    openFeedBack(feedback, feedbackId);
  };
  const showGuideIndex = ref(0);
  const hiddenGuide = () => {
    showGuideIndex.value = 0;
    localforageIns.setItem(firstEntry, true);
  };
  return {
    popupUrl,
    jumpVideo,
    jumpFeedBack,
    getPopupUrl,
    showGuideIndex,
    hiddenGuide
  };
};
